<?php

	// TITLE: Account_recovery AUTO MODEL
	// FILE: scaffolding/model/account_recovery.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createAccountRecovery = function($con, $accountRecovery) {
		$sql = 'INSERT INTO account_recovery (account_id, temporary_password, date, status_id) VALUES (';
		$sql .= $account_recovery->getAccountId() . ', ';
		$sql .= $account_recovery->getTemporaryPassword() . ', ';
		$sql .= $account_recovery->getDate() . ', ';
		$sql .= $account_recovery->getStatusId() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readAccountRecovery = function($con, $id) {
		$sql = 'SELECT * FROM account_recovery WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$accountRecovery = new AccountRecovery();
			$accountRecovery->setAccountId($dbio->select($readAccount(result[0])));
			$accountRecovery->setTemporaryPassword(result[1]);
			$accountRecovery->setDate(result[2]);
			$accountRecovery->setStatusId($dbio->select($readStatus(result[3])));
		} else {
			$accountRecovery = false;
		}
		return $accountRecovery;
	};

	$updateAccountRecovery = function($con, $accountRecovery) {
		$sql = 'UPDATE account_recovery SET ';
		$sql .= 'account_id = ' . $account_recovery->getAccountId() . ', ';
		$sql .= 'temporary_password = ' . $account_recovery->getTemporaryPassword() . ', ';
		$sql .= 'date = ' . $account_recovery->getDate() . ', ';
		$sql .= 'status_id = ' . $account_recovery->getStatusId() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteAccountRecovery = function($con, $id) {
		$sql = 'DELETE FROM account_recovery WHERE account_id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listAccountRecovery = function($con) {
		$sql = 'SELECT * FROM account_recovery';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$accountRecoverys = array();
			while ($result = mysqli_fetch_array($results)) {
				$accountRecovery = new AccountRecovery();
				$accountRecovery->setAccountId($dbio->select($readAccount(result[0])));
				$accountRecovery->setTemporaryPassword(result[1]);
				$accountRecovery->setDate(result[2]);
				$accountRecovery->setStatusId($dbio->select($readStatus(result[3])));
				$accountRecoverys[] = accountRecovery;
			}// end while
		} else {
			$accountRecoverys = false;
		}
		return $accountRecoverys;
	};

